#include "GameController.h"
#include "GameComponent.h"

#include <string>
using namespace std;

GameController *GameController::instance_ = NULL;

void
GameController::
registerComponent (GameComponent *comp) {
	components_.push_back(comp);
}

GameComponent *
GameController::
findComponent (const string& id) {
	for (vector<GameComponent *>::iterator itr = components_.begin(); itr != components_.end(); itr++) {
		GameComponent *cur = *itr;
		if (cur->getId().compare(id) == 0) {
			return cur;
		}
	}
	return NULL;
}

GameController::
~GameController () {
	for (vector<GameComponent *>::iterator itr = components_.begin(); itr != components_.end(); itr++) {
		// Delete each game component
		delete *itr;
	}
}

